----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/table_F1_share_domesticsales.log
  log type:  text
 opened on:  16 Dec 2022, 23:51:03

. *-------------------------------------------------------------------------------
. 
. 
. 
. 
. *Calculating the share of domestic sales in total revenues: foreign MNE affiliates vs. all firms.
. *------------------------------------------------------------------------
. clear all

. use "${data}/klems_oecd_unido_orbis_sales_emp_exp.dta", clear

. keep year isocode sector* exports EXP_usd_mnc GO_usd GO_usd_mnc

. order year isocode sector1 sector GO_usd exports GO_usd_mnc EXP_usd_mnc

. drop if sector1== sector
(3,120 observations deleted)

. 
. collapse (sum) GO_usd exports GO_usd_mnc EXP_usd_mnc, by(year isocode sector1)

. keep if year==2016
(1,920 observations deleted)

. keep if isocode=="EE" | isocode=="ES" | isocode=="IT" | isocode=="JP" | isocode=="SE" | isocode=="US" 
(136 observations deleted)

. 
. *Domestic intensity 
. *----------------------------------------------
. keep if sector1=="Manufacturing (C)" | sector1=="Market_Services (G-H-I-J-K-M-N-R-S-T)"
(12 observations deleted)

. gen xx=exports/GO_usd

. gen yy=EXP_usd_mnc/GO_usd_mnc

. 
. gen economy= 1-(exports/GO_usd)

. gen mnc= 1-(EXP_usd_mnc/GO_usd_mnc)

. gen ratio=economy/mnc

. sort  year isocode sector1

. drop xx yy 

. 
. gen type="NA"

. replace type="_manuf" if sector1=="Manufacturing (C)"
variable type was str2 now str6
(6 real changes made)

. replace type="_serv" if sector1=="Market_Services (G-H-I-J-K-M-N-R-S-T)"
(6 real changes made)

. 
. keep year isocode economy mnc ratio type

. reshape wide economy mnc ratio , i(year isocode) j(type) string
(note: j = _manuf _serv)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                       12   ->       6
Number of variables                   6   ->       8
j variable (2 values)              type   ->   (dropped)
xij variables:
                                economy   ->   economy_manuf economy_serv
                                    mnc   ->   mnc_manuf mnc_serv
                                  ratio   ->   ratio_manuf ratio_serv
-----------------------------------------------------------------------------

. format %9.2fc *manuf *serv

. 
. export delimited using "${rappendix}/table_F1_share_domesticsales.csv", datafmt replace
(note: file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/table_F1_share_domesticsales.cs
> v not found)
file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/table_F1_share_domesticsales.csv saved

. log close 
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/table_F1_share_domesticsales.log
  log type:  text
 closed on:  16 Dec 2022, 23:51:03
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
